<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="utf-8">
	<title>日志展示</title>
	
	<script th:src="@{/asserts/js/jquery.min.js}"></script>
	<script th:src="@{/asserts/ajax/libs/layer/layer.min.js}"></script>
	<script th:src="@{/asserts/ajax/libs/layui/layui.js}"></script>
	
	<!-- 根路径 -->
	<script type="text/javascript" th:inline="javascript">
		  ctx = /*[[@{/}]]*/'';
	</script>
</head>
<body style="height: 100%; overflow-y: scroll; background: #333; color: #aaa; padding: 10px;margin:0px 10px;padding:0px;">
<input type="hidden" id="taskId" th:value="${#request.getParameter('taskId')}" />

<pre id="log-container" class="console-output" style="margin-top:0px">
</pre>

<script type="text/javascript">

	function fetchNext(_start){
		var url = ctx+'portal/auto/autoTaskHistory/showLogger?start='+_start+'&taskId='+$("#taskId").val()
				
		$.post(url , function(response,status,xhr){
			showLogger(response) ; 
			
			var start = xhr.getResponseHeader("X-Text-Size") ; 
			
			if(xhr.getResponseHeader("X-More-Data") == "true") {
				setTimeout(function(){
					fetchNext(start);
				},1000);
			}
			
		}) ; 	
	}

	function showLogger(data){
		$("#log-container").append(data) ; // 接收服务端的实时日志并添加到HTML页面中
	}
	
	$(function() {
		fetchNext(0) ; 
	});
</script>
</body>
</html>